Namespace:
System.Collections.Concurrent
Assembly:
System.Threading (in System.Threading.dll)
Syntax
Visual Basic (Declaration) |
---|
Public Function GetOrAdd ( _
key As TKey, _
value As TValue _
) As TValue |
C# |
---|
public TValue GetOrAdd(
TKey key,
TValue value
) |
Parameters
- key
- Type: TKey
The key of the element to add.
- value
- Type: TValue
the value to be added, if the key does not already exist
Return Value
The value for the key. This will be either the existing value for the key if the
key is already in the dictionary, or the new value if the key was not in the dictionary.
Exceptions
Exception | Condition |
---|
System..::.ArgumentNullException | key is a null reference
(Nothing in Visual Basic). |
System..::.OverflowException | The dictionary contains too many
elements. |
See Also